import axios from 'axios'

const request = axios.create({
    baseURL: 'http://192.168.0.30:9090',
    timeout: 10000
});
// request.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8;multipart/form-data'

// 请求拦截器
request.interceptors.request.use(
    config => {
        const token = window.sessionStorage.getItem('token');
        token && (config.headers.token = token);
        // config.headers.token = token
        return config
    },
    error => {
        return Promise.error(error)
    });

// 响应拦截器
request.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data
        } else {
            return response.data
        }
    },
    // 服务器状态码不是200的情况
    error => {
        console.log(error)
        // if (error.response.status) {
        //     return Promise.reject(error.response)
        // }
    }
);
export default request
